package com.sk.sourcecircle.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;

import com.sk.sourcecircle.utils.UIUtils;

/**
 * Created by sk on 2017/12/20.
 */

public class TicketsRadioButton extends android.support.v7.widget.AppCompatRadioButton {

    private String ticketMoney = "";

    public String getTicketMoney() {
        return ticketMoney;
    }

    public void setTicketMoney(String ticketMoney) {
        this.ticketMoney = ticketMoney;
    }

    public TicketsRadioButton(Context context) {
        this(context, null);
    }

    public TicketsRadioButton(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TicketsRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setTextSize(38f);
        Rect rect = new Rect();
        paint.getTextBounds(ticketMoney, 0, ticketMoney.length(), rect);
        int width = rect.width();//文字宽
        int height = rect.height();//文字高
        Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.parseColor("#ff5050"));
        mPaint.setTextSize(38f);
        canvas.drawText(ticketMoney, getWidth() - width - UIUtils.dip2px(getContext(), 13), getHeight()-getMeasuredHeight()/2+height/2, mPaint);
    }


}
